<template>
	<view>
		<view class="head">将清空您的店铺数据，包括货品、客户、员工、订单库 存、账本、日报等数据。默认保留货品、客户、员工数 据，可手动选择清空。所有数据清空后不能在还原。</view>
		<view class="box">请选择要清空的数据</view>
		<view class="box-one">
			<view class="">货品</view>
			<view class="">
				<view><switch  @change="switch1Change" /></view>
			</view>
		</view>
		<view class="box-one">
			<view class="">客户</view>
			<view class="">
				<view><switch  @change="switch2Change" /></view>
			</view>
		</view>
		<view class="box-one">
			<view class="">员工</view>
			<view class="">
				<view><switch  @change="switch3Change" /></view>
			</view>
		</view>
		<view class="box-one">
			<view class="">供应商</view>
			<view class="">
				<view><switch  @change="switch4Change" /></view>
			</view>
		</view>
		<view class="box-one">
			<view class="">密码:</view>
			<view class=""><input type="text" value="" password placeholder="请输入登陆密码" v-model="password" /></view>
		</view>
		<view class="box-two">
			<view class="">统一某某某公司对因我决定而清空的数据不负责，请输 入“确定清空”表示您已确定！</view>
			<view class="in">
				<input type="text" value="" placeholder="请输入“确定清空”" v-model="trueClear" />
			</view>
		</view>
		<button type="primary" @click="clearA">确定</button>
	</view>
</template>

<script>
export default {
	data() {
		return {
			supplier:1,//供应商
			user:1,//员工
			customer:1,//顾客
			goods:1,
			trueClear:''
		};
	},
	methods: {
		switch1Change: function(e) {
			// console.log('switch1 发生 change 事件，携带值为', e.target.value);
			if(e.target.value==true){
				this.goods=0
				// console.log(this.customer);
			}else{
				this.goods=1
				// console.log(this.customer);
			}
		},
		switch2Change: function(e) {
			if(e.target.value==true){
				this.customer=0
				// console.log(this.customer);
			}else{
				this.customer=1
				// console.log(this.customer);
			}
		},
		switch3Change: function(e) {
			// console.log('switch3 发生 change 事件，携带值为', e.target.value);
			if(e.target.value==true){
				this.user=0
				
			}else{
				this.user=1
			
			}
		},
		switch4Change: function(e) {
			// console.log('switch4 发生 change 事件，携带值为', e.target.value);
			
			if(e.target.value==true){
				this.supplier=0
				// console.log(this.supplier);
			}else{
				this.supplier=1
				// console.log(this.supplier);
			}
		},
		clearA(){
			if(this.trueClear=='确定清空'){
				// console.log(456);
				this.$ajax('api/v1.shop/recovery',{
				    supplier:this.supplier,
					user:this.user,
					customer:this.customer,
					password:this.password,
					goods:this.goods,
				       }).then((res)=>{
				      // console.log(res);
					  uni.navigateTo({
					  	url:'../kitty-BasicLogin/login'
					  })
				       }).catch(res=>{
				        console.log(Error);
				       })
			}
			// console.log(123);
		}
	}
};
</script>

<style lang="scss">
page {
	background-color: #f7f4f8;
}
switch{
      transform: scale(0.8);
}
.head {
	font-size: 28rpx;
	font-family: PingFang SC;
	font-weight: 500;
	color: rgba(51, 51, 51, 1);
	line-height: 45rpx;
	background-color: #ffffff;
	padding: 41rpx 30rpx;
	box-sizing: border-box;
}

.box {
	height: 90rpx;
	line-height: 90rpx;
	font-size: 32rpx;
	font-family: PingFang SC;
	font-weight: 500;
	color: rgba(102, 102, 102, 1);
	padding: 0 30rpx;
}
.box-one {
	height: 110rpx;
	line-height: 110rpx;
	background-color: #ffffff;
	padding: 0 30rpx;
	display: flex;
	justify-content: space-between;
	font-size: 32rpx;
	font-family: PingFang SC;
	font-weight: 500;
	color: rgba(51, 51, 51, 1);
	margin-bottom: 20rpx;
	input {
		height: 100%;
	}
}
.box-two{
	height: 262rpx;
	background-color: #FFFFFF;
	padding: 30rpx;
	font-size:28rpx;
	font-family:PingFang SC;
	font-weight:500;
	color:rgba(51,51,51,1);
	line-height:42rpx;
}
	
.in{
	margin-top: 40rpx;
    width: 100%;
	height:70rpx;
		border:2px solid rgba(221,221,221,1);
		input{
			width: 600rpx;
			height: 70rpx;
			text-align: center;
		}
}
button{
	width: 80%;
	position: fixed;
	left: 50%;
	transform: translateX(-50%);
	bottom: 62rpx;
}
</style>
